<template>
  <div id="RebuildPanel" :class="{ smallFontSize: showEdition, mediumFontSize: !showEdition }">
    <!-- <div class="top">
      <img
        v-if="ISshowNowKNLX"
        style="width: 80%; margin: 0 auto"
        src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/YPC/11.png"
      />
      <img
        v-if="!ISshowNowKNLX"
        style="width: 80%; margin: 0 auto"
        src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/ZLJ/fgx.png"
      />
      <p>
        <span
          :style="{
            width: ISshowNowKNLX ? '31%' : '49%',
            display: 'inline-block',
            textAlign: 'left',
            paddingLeft: '2%',
          }"
          >危改申请</span
        >
        <span
          :style="{
            display: 'inline-block',
            textAlign: 'center',
            width: ISshowNowKNLX ? '31%' : '49%',
            paddingLeft: ISshowNowKNLX ? '0%' : '26%',
          }"
          >危改整治</span
        >
        <span
          v-show="ISshowNowKNLX"
          style="width: 33%; display: inline-block; text-align: center"
          >困难家庭补助申请</span
        >
      </p>
    </div> -->
    <div class="content">
      <div class="tab">
        <ul>
          <li
            v-for="(item, index) in tabData"
            :key="index"
            :class="{ select: nowIndex === index }"
            @click="tabClick(index)"
          >
            <span
              :class="{
                smallFontSize: showEdition,
                mediumFontSize: !showEdition,
              }"
              >{{ item }}</span
            >
          </li>
        </ul>
      </div>
      <div class="list">
        <p style="color: #989898; padding: 10px 0">请核对您的身份信息</p>
        <div v-if="nowIndex === 1">
          <p style="color: #5d5d5d; padding: 10px 0">
            <span style="color: #ff0000">*</span>
            请拍摄并上传被代办人的有效身份证
          </p>
          <div>
            <div style="width: 50%; float: left; text-align: center">
              <van-uploader v-model="fileList" :after-read="afterRead" :max-count="1">
                <template default>
                  <img src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/ZLJ/positive0.png" width="180" alt="" />
                </template>
              </van-uploader>
              <p :style="{ fontSize: showEdition ? '12px' : '14px' }">点击上传带头像的一面</p>
            </div>
            <div style="width: 50%; float: left; text-align: center">
              <van-uploader v-model="fileList1" :after-read="afterRead1" :max-count="1">
                <template default>
                  <img src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/ZLJ/positive1.png" width="180" alt="" />
                </template>
              </van-uploader>

              <p :style="{ fontSize: showEdition ? '12px' : '14px' }">点击上传带国徽的一面</p>
            </div>
          </div>
          <div style="clear: both"></div>
        </div>
        <van-form validate-first :class="{ smallFontSize: showEdition, mediumFontSize: !showEdition }">
          <div v-if="nowIndex === 1">
            <div class="formStyle">
              <span style="color: #ff0000">*</span>
              <van-field
                v-model="formDataNew.agentName"
                :readonly="isreadonsly2"
                label="代办人姓名"
                placeholder="请填写代办人姓名"
                :rules="[{ required: true, message: '请填写代办人姓名' }]"
              />
            </div>
            <div class="formStyle">
              <span style="color: #ff0000">*</span>
              <van-field
                v-model="formDataNew.agentPhone"
                label="代办人联系电话"
                :readonly="isreadonsly2"
                placeholder="请输入代办人联系电话"
                :rules="[
                  { required: true, message: '请填写代办人联系电话！' },
                  {
                    pattern: /^1[3456789]\d{9}$/,
                    message: '联系电话格式错误！',
                  },
                ]"
                name="pattern"
              />
            </div>
            <div class="formStyle">
              <span style="color: #ff0000">*</span>
              <van-field
                v-model="formDataNew.agentIdcard"
                label="代办人身份证号"
                :readonly="isreadonsly2"
                placeholder="请输入代办人身份证号"
                name="validator"
                :rules="[{ validator, message: '请输入正确身份证号码' }]"
              />
            </div>
          </div>
          <div class="formStyle" style="color: black">
            <span style="color: #ff0000">*</span>
            <van-field
              v-model="formDataNew.propertyPerson"
              :readonly="isreadonsly1"
              placeholder="请输入户主姓名"
              label="户主姓名"
              :rules="[{ required: true, message: '请填写户主姓名' }]"
            />
          </div>
          <div class="formStyle">
            <span style="color: #ff0000">*</span>
            <!--@blur.native.capture="handleGetCityData"-->
            <van-field
              v-model="formDataNew.householderIdcard"
              label="身份证号码"
              :readonly="isreadonsly1"
              name="validator"
              @blur.native.capture="handleGetCityData"
              placeholder="身份证号码"
              :rules="[{ validator, message: '请输入正确身份证号码' }]"
            />
            <van-button v-if="nowIndex === 1" @click="searchInformation(formDataNew.householderIdcard)" style="width: 80px;" size="small" type="info">信息查询</van-button>
          </div>
          <div class="formStyle">
            <span style="color: #ff0000">*</span>
            <!--{{formDataNew.householderPhone}}-->
            <van-field
              placeholder="请输入手机号码"
              :readonly="isreadonsly1"
              v-model="formDataNew.householderPhone"
              label="手机号"
              :rules="[
                { required: true, message: '请填写您的手机号码！' },
                { pattern: /^1[3456789]\d{9}$/, message: '手机号码格式错误！' },
              ]"
              name="pattern"
            />
          </div>
          <div class="formStyle">
            <span style="color: #ff0000">*</span>
            <van-field
              readonly
              clickable
              name="picker"
              :value="formDataNew.isHasHouse | inUseName(ENUM.SFYFARR)"
              label="是否有房"
              placeholder="请选择是否有房"
              @click="ENUM.SFYF = true"
            />
            <van-popup v-model="ENUM.SFYF" position="bottom" get-container="#popup">
              <van-picker
                show-toolbar
                :columns="ENUM.SFYFARR"
                value-key="DICNAME"
                @confirm="onConfirmSFYF"
                @cancel="ENUM.SFYF = false"
              />
            </van-popup>
          </div>
          <div class="formStyle">
            <span style="color: #ff0000">*</span>
            <van-field
              readonly
              placeholder="请选择是否困难家庭"
              :value="formDataNew.userType | inUseName(ENUM.SFYFARR)"
              label="是否困难家庭"
              @click="ENUM.KNLX = true"
              name="pattern"
            />
            <van-popup v-model="ENUM.KNLX" position="bottom" get-container="#popup">
              <van-picker
                show-toolbar
                :columns="ENUM.SFYFARR"
                value-key="DICNAME"
                @confirm="onConfirmKNLX"
                @cancel="ENUM.KNLX = false"
              />
            </van-popup>
          </div>
          <div class="formStyle">
            <span style="color: #ff0000">*</span>
            <van-field
              readonly
              clickable
              name="picker"
              :value="ValueCity"
              label="所属市"
              placeholder="请选择所属市"
              @change="getXianOpenDataView"
              @click="showPickerC = true"
              :rules="[{ required: true, message: '请选择所属市' }]"
            />
            <van-popup v-model="showPickerC" position="bottom" get-container="#popup">
              <van-picker
                show-toolbar
                :columns="CityColumns"
                value-key="cityname"
                @confirm="onConfirmCity"
                @cancel="showPickerC = false"
              />
            </van-popup>
          </div>
          <div class="formStyle">
            <span style="color: #ff0000">*</span>
            <van-field
              readonly
              clickable
              name="picker"
              :value="valueXian"
              label="所属县(区)"
              placeholder="请选择所属县(区)"
              @click="showPickerX = true"
            />
            <van-popup v-model="showPickerX" position="bottom" get-container="#popup">
              <van-picker
                show-toolbar
                :columns="XianColumns"
                value-key="cityname"
                @confirm="onConfirmXian"
                @cancel="showPickerX = false"
              />
            </van-popup>
          </div>
          <div class="formStyle">
            <span style="color: #ff0000">*</span>
            <van-field
              readonly
              clickable
              name="picker"
              :value="valueZhen"
              label="所属镇"
              placeholder="请选择所属镇"
              @click="showPickerT = true"
            />
            <van-popup v-model="showPickerT" position="bottom" get-container="#popup">
              <van-picker
                show-toolbar
                :columns="TownColumns"
                value-key="cityname"
                @confirm="onConfirmTown"
                @cancel="showPickerT = false"
              />
            </van-popup>
          </div>
          <div class="formStyle">
            <span style="color: #ff0000">*</span>
            <van-field
              readonly
              clickable
              name="picker"
              :value="valueCun"
              label="所属村"
              placeholder="请选择所属村"
              @click="showPickerCun = true"
            />
            <van-popup v-model="showPickerCun" position="bottom" get-container="#popup">
              <van-picker
                show-toolbar
                :columns="CunColumns"
                value-key="cityname"
                @confirm="onConfirmCun"
                @cancel="showPickerCun = false"
              />
            </van-popup>
          </div>
          <div class="formStyle">
            <span style="color: #ff0000">*</span>
            <van-field placeholder="请输入房屋地址" v-model="formDataNew.detailAddress" label="房屋地址" name="pattern" />
          </div>
          <div class="formStyle">
            <!--<span style="color: #FF0000;">*</span>-->
            <van-field placeholder="请输入建筑层数" v-model="formDataNew.buildFloor" label="建筑层数" name="pattern" />
          </div>
          <div class="formStyle">
            <van-field
              readonly
              clickable
              name="datetimePicker"
              v-model="formDataNew.buildYear"
              label="建造年份"
              placeholder="请选择建造年份"
              @click="showPickerN = true"
            />
            <van-popup v-model="showPickerN" position="bottom" get-container="#popup">
              <van-picker show-toolbar :columns="yearsToNow" @confirm="onConfirmN" @cancel="showPickerN = false" />
            </van-popup>
          </div>
          <div v-if="formDataNew.userType == '0'" class="formStyle" style="color: black">
            <span style="color: #ff0000">*</span>
            <!--<van-field-->
              <!--readonly-->
              <!--v-model="formData.JDJG"-->
              <!--label="公司名称"-->
              <!--placeholder="请选择鉴定公司"-->
              <!--@click="selectAuthenticate"-->
            <!--/>-->
            <van-field
              readonly
              clickable
              name="picker"
              :value="formData.JDJG"
              label="公司名称"
              placeholder="请选择鉴定公司"
              @click="showJDGS = true"
            />
            <van-popup v-model="showJDGS" position="bottom" get-container="#popup">
              <van-picker
                show-toolbar
                :columns="JDGSData"
                value-key="COMAPNY_NAME"
                @confirm="onConfirmJDGS"
                @cancel="showJDGS = false"
              />
            </van-popup>
          </div>
          <div>
            <div v-for="(item, index) in listData" :key="index">
              <p
                :class="{
                  smallFontSize: showEdition,
                  mediumFontSize: !showEdition,
                }"
                style="display: flex; align-items: center"
              >
                {{ item.name }}
              </p>
              <div style="width: 100vw; overflow: auto">
                <van-uploader
                  @click-upload="getList(item)"
                  :after-read="afterReadFK"
                  :before-delete="delectFile"
                  v-model="item.fileList"
                  multiple
                />
              </div>
            </div>
          </div>
        </van-form>
      </div>
    </div>
    <div style="height: 90px">
      <div :style="{ fontSize: showEdition ? '12px' : '14px' }" class="bottomText">
        请确保资料真实有效，我们会第一时间受理您的危房申请
      </div>
      <div class="bottomBtn" @click="SaveData">提交</div>
    </div>
    <van-dialog v-model="showDialogWXTS" title="温馨提示" @confirm="confirm" confirmButtonColor="#000">
      <span style="display: inline-block; width: 100%; text-align: center; padding: 10px">
        当前申请人非户籍户主,请户籍户主本人发起危改申请流程或在 “<span style="color: #3f8ffc">为他人待办</span>”
        模块为户主发起待办</span
      >
    </van-dialog>
    <!-- <div>
      <img src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/DSF/我要危改.png" alt="" width="100%">
    </div> -->
  </div>
</template>

<script>
import {
  QuerySignCallback,
  InsertDataView,
  PrepareCreateProcess,
  CreateProcess,
  PlatSendTask,
  getRegister1,
  getRegister,
  getSystemCityCode,
  getDatalistForTree,
  FileServerProxy,
  FileServerUpload,
  dataTransFile,
  dataServerOpenDataView,
  debounce,
  DelectFile,
  GetFileData,
  existHouseBaseInfo,
  dataTransFilePreview,
  getApplyPersonInfoByIdCard,
  saveApplyPersonInfo,
  appraisal
} from '@/utils/api'
import { Dialog } from 'vant'
import Pubsub from 'pubsub-js'
import { v4 as uuidv4 } from 'uuid'
export default {
  data() {
    let self = this
    return {
      showJDGS:false,
      showDialogWXTS: false,
      KNLX: '',
      isreadonsly1: true,
      isreadonsly2:true,
      showPickerN: false,
      ENUM: {
        SFYF: false,
        KNLX: false,
        SFYFARR: [
          {
            DICNAME: '是',
            DICID: '1',
          },
          {
            DICNAME: '否',
            DICID: '0',
          },
        ],
        // JDLXARR: [],
        // JDLX: false,
        // JDDJARR: [],
        // JDDJ: false,
        // JWFSARR: [],
        // JWFS: false,
        // JWFSName: "",
        // showPickerfk: false,
        // KNLXARR: [],
        // KNLX: false,
        // // IFJDBG:false,
        // // IFJDBGARR:[],
        // JDJG: false,
        // JDJGARR: [],
      },
      listData: [
        // {
        //   name: '房屋照片',
        //   groupGuid: '8188d4d5-0898-44b9-b7f9-4f84dfb58f11',
        //   fileList:[]
        // },
        // {
        //   name: '鉴定报告',
        //   groupGuid: '88d711ba-870c-40f2-a81d-71df8caeefd4',
        //   fileList:[]
        // }
      ],
      yearsToNow: [],
      columnsJWFS: [
        {
          text: '1',
          value: '1',
        },
      ],
      showPickerq: false,
      currentDate: new Date(),
      parentName: '',
      showEdition: false,
      showPickerJFLY: false,
      showPickerJFLY1: false,
      ISshowNow: false,
      phone: window.localStorage.getItem('DanDianPhone')
        ? self.plusXing(window.localStorage.getItem('DanDianPhone'), 3, 5)
        : '',
      idCard: window.localStorage.getItem('DanDianid')
        ? self.plusXing(window.localStorage.getItem('DanDianid'), 6, 8)
        : '',
      username: '',
      fileList: [],
      fileList1: [],
      tableData1: [],
      tableFrom: {
        XM: '',
        SFZH: '',
        sexx: '',
        phone: '',
        JTZZ: '',
        To_row_guid: '',
      },
      ValueCity: '',
      valueXian: '',
      valueZhen: '',
      valueCun: '',
      buildtype: '',
      If_ljf: '',
      ValueCity3: '',
      valueXian3: '',
      valueZhen3: '',
      valueCun3: '',
      If_ljf1: '',
      nowIndex: 0,
      dialogTitle: '',
      showDialog: false,
      text: '',
      IsLG: '',
      formDataNew:{
        agentName:'',
        agentPhone:'',
        agentIdcard:'',
        propertyPerson:'',
        householderIdcard:'',
        householderPhone:'',
        isHasHouse:'',
        userType:'',
        cityCode:'',
        detailAddress:'',
        buildFloor:'',
        buildYear:'',
        uscc:'',
        objectNo:'',

      },
      formData: {
        SQR: '',
        ZJH: '',
        SJH: '',
        SCITY: '',
        XCITY: '',
        ZCITY: '',
        CCITY: '',
        KNLX: '',
        CS: '',
        NF: '',
        FWDZ: '',
        DBRXM: '',
        DBRSJH: '',
        DBRZJH: '',
        SQSJ: '',
        JDJG: '',
        TYSHXYDM: '',
        DWDZ: '',
        IFYF: '',
      },
      formDataTR: {
        DBRXM: window.localStorage.getItem('DanDianName')
          ? self.plusXing(window.localStorage.getItem('DanDianName'), 0, 1)
          : '',
        DBRSJH: window.localStorage.getItem('DanDianPhone')
          ? self.plusXing(window.localStorage.getItem('DanDianPhone'), 3, 5)
          : '',
        DBRZJH: window.localStorage.getItem('DanDianid')
          ? self.plusXing(window.localStorage.getItem('DanDianid'), 6, 8)
          : '',
        SQR: '',
        ZJH: '',
        SJH: '',
        SCITY: '',
        XCITY: '',
        ZCITY: '',
        CCITY: '',
        If_ljf: '',
        buildtype: '',
        buildreason: '',
        buildreason_qt: '',
      },
      ISshowNowKNLX: true,
      sendData: [],
      value: '',
      JFLYcolumns: [],
      columns1: ['是', '否'],
      columns2: ['有', '无'],
      showPicker: false,
      tabData: ['本人申请', '为他人代办'],
      tableData: [],
      showPicker1: false,
      CityColumns: [],
      showPickerC: false,
      cityCode: '',
      XianColumns: [],
      showPickerX: false,
      TownColumns: [],
      showPickerT: false,
      CunColumns: [],
      showPickerCun: false,
      BUILDTYPEcolumns: [],
      showPickerBT: false,
      addNum: 0, //  0本人已提交的，1 他人代办中的
      multipleSelection: [],
      multipleSelection1: [],
      isAdd: true,
      JDGSData:[
        // {
        //   COMAPNY_NAME:'杭州恒信电气有限公司',
        //   TYSHXYDM:'913301857471537181'
        // }
      ]
    }
  },
  filters: {
    inUseName: function (msg, data) {
      let name = ''
      data.forEach((item) => {
        if (item.DICID == msg) {
          name = item.DICNAME
        }
      })
      return name
    },
  },
  watch: {},
  methods: {
    searchInformation: async function(data){
      // 330227194910017000
      const res = await getApplyPersonInfoByIdCard(data)
      if (res.data.data.length > 0) {
         for (let i in this.formDataNew) {
           if (i!=='propertyPerson' && i!=='householderIdcard' && i!=='householderPhone' && i!=='agentName' && i!=='agentPhone' && i!=='agentIdcard'){
             if (res.data.data[0][i]) {
               this.formDataNew[i] = res.data.data[0][i]
             }
           }
         }
      }
      this.ValueCity = res.data.data[0].belongCity
      // this.ValueCity = this.inUseName(this.formData.SCITY, this.CityColumns)
      // this.formData.XCITY = res.data.data[0].belongCounty
      this.valueXian = res.data.data[0].belongCountry
      this.valueZhen = res.data.data[0].belongTown
      this.valueCun = res.data.data[0].belongVillage
      // this.formData.ZCITY = res.data.data[0].belongTown
      // this.ValueCity = this.inUseName(this.formData.SCITY, this.CityColumns)
      // this.formData.CCITY = res.data.data[0].belongVillage
      // this.ValueCity = this.inUseName(this.formData.SCITY, this.CityColumns)
      // if (this.formData.SCITY) {
      //   this.getXianOpenDataView(this.formData.SCITY)
      // }
      // if (this.formData.XCITY) {
      //   this.getTownOpenDataView(this.formData.XCITY)
      // }
      // if (this.formData.ZCITY) {
      //   this.getCunOpenDataView(this.formData.ZCITY)
      // }
      // belongCity
      //   :
      //   "330600000000"
      // belongCounty
      //   :
      //   "330624000000"
      // belongProvince
      //   :
      //   "330000000000"
      // belongTown
      //   :
      //   "330624200000"
      // belongVillage
      //   :
      //   "330624200249"
    },
    //根据身份证查询户主户籍姓名和身份证匹配
    handleMatching: async function (data, data1) {
      let params = {
        accessCode: '4f54f932615d11ec87416805cab640a0',
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',

        params: { czrkgmsfhm: data },
      }
      const res = await FileServerProxy(params)
      try {
        if (res.data.data.datas == null) {
          this.isGOTo = true
          // this.$toast.fail('当前填写的户主身份证号码暂无信息!')
        } else {
          //优化提醒
          res.data.data.datas.forEach((item) => {
            if (item.ELC_LICENCE_STRUCT.DATA.CZRKGMSFHM == data) {
              if (item.ELC_LICENCE_STRUCT.DATA.CZRKXM == data1) {
                this.isGOTo1 = true
              } else {
                this.$toast.fail('当前填写的申请人姓名和身份证号码不匹配!')
                this.isGOTo1 = false
              }
            }
          })
        }
      } catch (err) {
        this.$toast.fail('请稍后重试!')
      }
    },
    //根据身份证查询代办人户籍姓名和身份证匹配
    handleMatching1: async function (data, data1) {
      let params = {
        accessCode: '4f54f932615d11ec87416805cab640a0',
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',

        params: { czrkgmsfhm: data },
      }
      const res = await FileServerProxy(params)
      try {
        if (res.data.data.datas == null) {
          this.isGOTo1 = true
          // this.$toast.fail('当前填写的代办人身份证号码暂无信息!')
        } else {
          //优化提醒
          res.data.data.datas.forEach((item) => {
            if (item.ELC_LICENCE_STRUCT.DATA.CZRKGMSFHM == data) {
              if (item.ELC_LICENCE_STRUCT.DATA.CZRKXM == data1) {
                this.isGOTo1 = true
              } else {
                this.$toast.fail('当前填写的代办人姓名和身份证号码不匹配!')
                this.isGOTo1 = false
              }
            }
          })
        }
      } catch (err) {
        this.$toast.fail('请稍后重试!')
      }
    },
    selectAuthenticate() {
      let JDData = {
        nowIndex: this.nowIndex,
        formData: this.formData
      }
      window.localStorage.setItem(
        "JDData",
         JSON.stringify(JDData)
      );
      this.$router.push({
        path: '/authenticateUnitlist',
        query: {
          data: this.formData,
          nowIndex: this.nowIndex,
          rowGuid: this.rowGuid,
        },
      })
    },
    confirm() {
      this.nowIndex = 1
    },
    inUseName: function (msg, data) {
      let name = ''
      data.forEach((item) => {
        if (item.citycode == msg) {
          name = item.cityname
        }
      })
      return name
    },
    onConfirmN(data) {
      this.formDataNew.buildYear = data
      this.showPickerN = false
    },
    onConfirmSFYF(data) {
      this.formDataNew.isHasHouse = data.DICID
      this.ENUM.SFYF = false
    },
    onConfirmJDGS(data){
      this.formData.JDJG = data.COMAPNY_NAME
      this.formDataNew.uscc = data.TYSHXYDM
      this.showJDGS = false
    },
    onConfirmKNLX(data) {
      this.formDataNew.userType = data.DICID
      this.ENUM.KNLX = false
    },
    getData: async function () {
      let params = {
        accessCode: '688bd3883572440a859dfd8ba9194e7b',
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: {
          dataguid: '0326e06f-4ba2-4361-a7c0-06a55b31708f',
          searchObject: JSON.stringify([{ field: 'row_guid', value: this.rowData.ROW_GUID, operator: '=' }]),
          token: window.localStorage.getItem('token'),
        },
      }
      const res = await FileServerProxy(params)
      let data = JSON.parse(res.data.data).Data
      if (data.length > 0) {
        for (let i in this.formData) {
          this.formData[i] = data[0][i]
        }
      }
      if (data.length > 0) {
        this.ROW_GUID = data[0].ROW_GUID
        this.isAdd = false
      } else {
        this.ROW_GUID = this.newGuid()
        this.isAdd = true
      }
    },
    SaveData: async function () {
      // let Base64 = require("js-base64").Base64;
      if (this.nowIndex==0) {
        if (
          this.formDataNew.propertyPerson.indexOf('*') !== -1 ||
          this.formDataNew.householderIdcard.indexOf('*') !== -1 ||
          this.formDataNew.householderPhone.indexOf('*') !== -1
        ) {
          this.formDataNew.propertyPerson = window.localStorage.getItem('DanDianName')
          this.formDataNew.householderIdcard = window.localStorage.getItem('DanDianid')
          this.formDataNew.householderPhone = window.localStorage.getItem('DanDianPhone')
        }
      }else{
        if (
          this.formDataNew.agentName.indexOf('*') !== -1 ||
          this.formDataNew.agentIdcard.indexOf('*') !== -1 ||
          this.formDataNew.agentPhone.indexOf('*') !== -1
        ) {
          this.formDataNew.agentName = window.localStorage.getItem('DanDianName')
          this.formDataNew.agentIdcard = window.localStorage.getItem('DanDianid')
          this.formDataNew.agentPhone = window.localStorage.getItem('DanDianPhone')
        }
      }
      let params = this.formDataNew
      const res = await saveApplyPersonInfo(params)
      if (res.data.data) {
        let params1 = {
          "objectNo":res.data.data == true ? this.formDataNew.objectNo : res.data.data,
          "userName":window.localStorage.getItem('DanDianName'),
          "authCompanyName":this.formData.JDJG,
          "socialCreditCode":this.formDataNew.uscc,
          "recheck":0,
          "token": window.localStorage.getItem('token'),
           isAuth: "否",
           "authLevel":"D"
        }
        const res1 = await appraisal(params1)
        console.log(res1)
        if (res1.data.data){
          this.$router.push({
            path: '/ZLJIndex',
          })
        }else{
          this.$toast.fail(res1.data.msg)
        }
      }
      // console.log(res)
    },
    StoredProcedure: async function () {
      setTimeout(() => {
        this.$router.push({
          path: '/TreeSelectZLWG',
          query: { data: this.formData, list: false },
        })
      }, 500)
    },
    getList(item) {
      this.groupGuids = item.groupGuid
    },
    afterReadFK(file) {
      // 此时可以自行将文件上传至服务器
      this.getFileServerUpload2(file.file)
    },
    getFileServerUpload2: async function (file) {
      // let formData = new FormData();
      // formData.append("file", file);
      // formData.append("toRowGuid", this.rowGuid);
      // formData.append("groupGuid", this.groupGuids);
      // formData.append("token", window.localStorage.getItem("token"));
      // const res = await FileServerUpload(formData);
      // if (res.data.Success == true) {
      //   this.$notify({ type: "success", message: "上传成功!" });
      // }
      let data = {
        toRowGuid: this.rowGuid,
        groupGuid: this.groupGuids,
        token: window.localStorage.getItem('token'),
      }
      let formData = new FormData()
      formData.append('file', file)
      formData.append('accessCode', '7a3fc061c866434b8475d3775c9ddcea')
      formData.append('cityCode',  window.localStorage.getItem("citycode")
              ? window.localStorage.getItem("citycode")
              : "441300000000")
      formData.append('token', window.localStorage.getItem('token'))
      formData.append('paramStr', JSON.stringify(data))
      const res = await dataTransFile(formData)
      let data1 = JSON.parse(res.data.data).FileList
      this.fileGuid = data1[0].FILEGUID
      if (data1[0].FILEGUID) {
        this.$toast.success('上传成功!')
      }
    },
    delectFile: async function (file) {
      let fileguid = ''
      if (file.ROW_GUID) {
        fileguid = file.ROW_GUID
      } else {
        fileguid = this.fileGuid
      }
      if (fileguid) {
        let params = {
          accessCode: 'ce9b691634de4ebca68dc5bb638d07f4',
          cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
          params: {
            fileGuid: fileguid,
            token: window.localStorage.getItem('token'),
          },
        }
        const res = await FileServerProxy(params)
        let data = JSON.parse(res.data.data).Success
        if (data) {
          this.$toast.success('删除成功!')
        }
      }
    },
    onConfirmJDJG(data) {
      this.formData.JDJG = data.QYZZMC
      this.formData.JDJGFZR = data.ST_NAME
      this.formData.JDJGID = data.ST_ID
      this.ENUM.JDJG = false
    },
    // 枚举
    getEnumeration: async function () {
      // let params = {
      //   accessCode: "688bd3883572440a859dfd8ba9194e7b",
      //      cityCode: window.localStorage.getItem("citycode")
      // ? window.localStorage.getItem("citycode")
      // : "441300000000",
      //   params: {
      //     dataguid: "b15c9597-ccb8-435c-b43d-06fe30fc0e08",
      //     searchObject: JSON.stringify([]),
      //     token: window.localStorage.getItem("token"),
      //   },
      // };
      // const res = await FileServerProxy(params);
      this.getEnum('b15c9597-ccb8-435c-b43d-06fe30fc0e08')
      this.getEnum('c7007467-d12c-4b87-948e-aa58b2df2131')
      this.getEnum('92f63613-9186-4a84-ba66-d098614e07a6')
      this.getEnum('86d6eb80-8bcb-49f6-b5c3-462ac1ae585d')
      this.getEnum('218d5aef-2111-4f82-b435-55ef7bdbd973')
      this.getEnum('b3be00d8-bd87-4601-8ef0-9b7b0c8929cf')
    },
    getEnum: async function (viewID) {
      // let token = window.localStorage.getItem("token");
      // const res = await dataServerOpenDataView(viewID, [], token);
      let params = {
        accessCode: '688bd3883572440a859dfd8ba9194e7b',
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: {
          dataguid: viewID,
          searchObject: JSON.stringify([]),
          token: window.localStorage.getItem('token'),
        },
      }
      const res = await FileServerProxy(params)
      switch (viewID) {
        case 'b15c9597-ccb8-435c-b43d-06fe30fc0e08':
          this.ENUM.JDLXARR = JSON.parse(res.data.data).Data
          break
        case 'c7007467-d12c-4b87-948e-aa58b2df2131':
          this.ENUM.JDDJARR = JSON.parse(res.data.data).Data
          break
        case '92f63613-9186-4a84-ba66-d098614e07a6':
          this.ENUM.JWFSARR = JSON.parse(res.data.data).Data
          break
        case '86d6eb80-8bcb-49f6-b5c3-462ac1ae585d':
          this.ENUM.KNLXARR = JSON.parse(res.data.data).Data
          break
        case '218d5aef-2111-4f82-b435-55ef7bdbd973':
          this.ENUM.IFJDBGARR = JSON.parse(res.data.data).Data
          break
        case 'b3be00d8-bd87-4601-8ef0-9b7b0c8929cf':
          this.ENUM.JDJGARR = JSON.parse(res.data.data).Data
          break
        default:
          break
      }
    },
    validator(val) {
      var idcardReg =
        /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/
      return idcardReg.test(val)
    },
    afterRead(file) {
      this.getFileServerUpload(file.file, '0')
    },
    plusXing(str, frontLen, endLen) {
      //浙里办新规则
      if (str.length < 9) {
        return '*' + str.substring(1, str.length) //截取name 字符串截取第一个字符
      } else if (str.length > 9 && str.length < 18) {
        return str.substring(0, 3) + '****' + str.substring(7, str.length) //截取第一个和大于第4个字符
      } else {
        return str.substring(0, 1) + '****************' + str.substring(str.length - 1, str.length)
      }
    },
    afterRead1(file) {
      // 此时可以自行将文件上传至服务器
      // this.getFileServerUpload(file.file)
      //   ZWJSBridge.chooseImage({
      //     "upload": true
      //   }).then(res => {
      this.getFileServerUpload(file.file, '1')
      //   }).catch(err => {
      //   })
    },
    getFileServerUpload: async function (file, data) {
      // let formData = new FormData();
      // formData.append("file", file);
      // formData.append("toRowGuid", this.rowGuid);
      // formData.append(
      //   "groupGuid",
      //   data == "0"
      //     ? "19902700-f952-4561-a338-5590056dab65"
      //     : "d26fd8fd-0d8a-46ec-af9f-2341ba78fb58"
      // );
      // formData.append("token", window.localStorage.getItem("token"));
      let data1 = {
        toRowGuid: this.rowGuid,
        groupGuid: data == '0' ? '19902700-f952-4561-a338-5590056dab65' : 'd26fd8fd-0d8a-46ec-af9f-2341ba78fb58',
        token: window.localStorage.getItem('token'),
      }
      let formData = new FormData()
      formData.append('file', file)
      formData.append('accessCode', '7a3fc061c866434b8475d3775c9ddcea')
      formData.append(
        'cityCode',
        window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000'
      )
      formData.append('paramStr', JSON.stringify(data1))
      // const res = await FileServerUpload(formData);
      const res = await dataTransFile(formData)
      let data2 = JSON.parse(res.data.data).FileList
      this.fileGuid = data2[0].FILEGUID
      if (data2[0].FILEGUID) {
        this.$toast.success('上传成功!')
      }
      // if (res.data.Success == true) {
      //   this.$toast.success("上传成功!");
      // }
    },
    //根据身份证信息获取是哪个地市
    handleGetCityData: async function (data) {
      //
      this.getDifficult()
      if (this.nowIndex == 0) {
        let params = {
          accessCode: '4f54f932615d11ec87416805cab640a0',
          cityCode: '',

          params: { czrkgmsfhm: this.formData.ZJH },
        }
        const res = await FileServerProxy(params)
        // res.data.datas[0].DATA
        // 调用接口获取正确的信息
        if (res.data.data.datas == null) {
          // this.$toast.fail('非本省人员无法申请建房');
          // this.$notify({ type: 'warning', message: '非本省人员无法申请建房' });
        } else {
          let parmes = {
            accessCode: '3b9bff397b31401ea57b35b384a94673',

            cityCode: '',
            townName: res.data.data.datas[0].ELC_LICENCE_STRUCT.DATA.XZJD,
            fullVillageName: res.data.data.datas[0].ELC_LICENCE_STRUCT.DATA.CZRKZZ,
            townCode: res.data.data.datas[0].ELC_LICENCE_STRUCT.DATA.SSPCSJGDM,
            villageName: res.data.data.datas[0].ELC_LICENCE_STRUCT.DATA.CJWH,
          }
          const res1 = await getSystemCityCode(parmes)
          try {
            res1.data.data.forEach((item) => {
              this.ValueCity3 = item.child[0].pid
              this.ValueCity = item.child[0].cityName
              this.valueXian3 = item.child[0].child[0].pid
              this.valueXian = item.child[0].child[0].cityName
              this.valueZhen3 = item.child[0].child[0].child[0].pid
              this.valueZhen = item.child[0].child[0].child[0].cityName
              this.valueCun3 = item.child[0].child[0].child[0].child[0].pid
              this.valueCun = item.child[0].child[0].child[0].child[0].cityName
            })
          } catch (error) {
            if (this.ValueCity3 == '' || this.valueXian3 == '' || this.valueZhen3 == '' || this.valueCun3 == '') {
              this.$toast.fail('户籍地址和现有地址不匹配,请手动选择！')
              // this.$notify({ type: 'warning', message: '户籍地址和现有地址不匹配,请手动选择！' });
            }
          }
        }
      } else {
        let params = {
          accessCode: '4f54f932615d11ec87416805cab640a0',
          cityCode: '',

          params: { czrkgmsfhm: this.formData.ZJH },
        }
        const res = await FileServerProxy(params)
        // res.data.datas[0].DATA
        let parmes = {
          accessCode: '',
          cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '',
          townName: res.data.data.datas[0].ELC_LICENCE_STRUCT.DATA.XZJD,
          fullVillageName: res.data.data.datas[0].ELC_LICENCE_STRUCT.DATA.CZRKZZ,
          townCode: res.data.data.datas[0].ELC_LICENCE_STRUCT.DATA.SSPCSJGDM,
          villageName: res.data.data.datas[0].ELC_LICENCE_STRUCT.DATA.CJWH,
        }
        const res1 = await getSystemCityCode(parmes)
        res1.data.data.forEach((item) => {
          this.ValueCity3 = item.child[0].pid
          this.ValueCity = item.child[0].cityName
          this.valueXian3 = item.child[0].child[0].pid
          this.valueXian = item.child[0].child[0].cityName
          this.valueZhen3 = item.child[0].child[0].child[0].pid
          this.valueZhen = item.child[0].child[0].child[0].cityName
          this.valueCun3 = item.child[0].child[0].child[0].child[0].pid
          this.valueCun = item.child[0].child[0].child[0].child[0].cityName
        })
      }
    },
    saveBtn() {
      if (this.tableFrom.XM && this.tableFrom.SFZH && this.tableFrom.phone) {
        if (this.addNum == 0) {
          this.tableData.push(this.tableFrom)
          this.tableData = Array.from(new Set(this.tableData))
        } else {
          this.tableData1.push(this.tableFrom)
          this.tableData1 = Array.from(new Set(this.tableData1))
        }
        this.cancelBtn()
      } else {
        this.$toast.fail('请填写必填项!')
        // this.$notify({ type: 'waring', message: '请填写必填项!' });
      }
    },
    cancelBtn() {
      this.tableFrom = {
        name: '',
        sfzh: '',
        iphone: '',
        jtdz: '',
      }
      this.showDialog = false
    },
    // 保存表格数据
    getCityOpenDataView: async function () {
      this.CityColumns = []
      // let dataGuid = "e9c98787-4966-4365-80b0-c1cc678c6f85";
      // let searchObject = [];
      // let token = window.localStorage.getItem("token");
      // let params = {
      //   accessCode: "688bd3883572440a859dfd8ba9194e7b",

      //   cityCode: window.localStorage.getItem("citycode")
      //     ? window.localStorage.getItem("citycode")
      //     : "441300000000",
      //   params: {
      //     dataguid: dataGuid,
      //     searchObject: searchObject,
      //     token: token,
      //   },
      // };
      const res = await getDatalistForTree('330000000000')
      this.CityColumns = res.data.data
      this.CityColumns.forEach((item) => {
        if (item.citycode == window.localStorage.getItem('citycode')) {
          this.cityCode = item.citycode
          this.ValueCity = item.cityname
          this.ValueCity1 = item.cityname
          this.formData.SCITY = item.citycode
          // this.formDataTR.S = item.citycode;
          // this.formDataGJ.SCITY = item.citycode;
          this.showPickerC = false
        }
      })
      this.getXianOpenDataView(window.localStorage.getItem('citycode'))
      if (this.$route.query.data) {
        let Base64 = require('js-base64').Base64
        let data = JSON.parse(this.$route.query.data)
        let cityCode = data.FWTYBH_EXT
        this.existHouseBaseInfo = data
        // this.formData.SQR = Base64.decode(data.HZXX_INFO.HZXM)
        // this.formData.ZJH = Base64.decode(data.HZXX_INFO.HZSFZH)
        // this.formData.SJH = Base64.decode(data.HZXX_INFO.HZDH)
        this.formData.SQR = this.namePrivate(Base64.decode(data.HZXX_INFO.HZXM))
        this.formData.ZJH = Base64.decode(data.HZXX_INFO.HZSFZH).replace(/^(.{6})(?:\d+)(.{4})$/, '$1****$2')
        var pho = /(\d{3})\d*(\d{4})/
        this.formData.SJH = Base64.decode(data.HZXX_INFO.HZDH).replace(pho, '$1****$2')
        this.formData.SCITY = cityCode.substring(0, 4) + '00000000'
        this.ValueCity = this.inUseName(this.formData.SCITY, this.CityColumns)
        this.formData.XCITY = cityCode.substring(0, 6) + '000000'
        this.getXianOpenDataView(this.formData.SCITY)
        this.formData.ZCITY = cityCode.substring(0, 9) + '000'
        this.getTownOpenDataView(this.formData.XCITY)
        this.formData.CCITY = cityCode
        this.getCunOpenDataView(this.formData.ZCITY)
        this.formData.CS = data.JZCS
        this.formData.NF = data.JSNF
        this.formData.FWDZ = data.XXDZ
      } else if (this.$route.query.data2) {
        let data = this.$route.query.data2
        this.formData.SCITY = this.$route.query.data2.SCITY
        this.ValueCity = this.inUseName(this.formData.SCITY, this.CityColumns)
        this.formData.XCITY = this.$route.query.data2.XCITY
        this.getXianOpenDataView(this.formData.SCITY)
        this.formData.ZCITY = this.$route.query.data2.ZCITY
        this.getTownOpenDataView(this.formData.XCITY)
        this.formData.CCITY = this.$route.query.data2.CCITY
        this.getCunOpenDataView(this.formData.ZCITY)
      } else {
        if (this.formData.ZJH && this.formData.SQR) {
          this.getNHData()
        }
      }
    },
    getXianOpenDataView: async function (data) {
      // alert(8)

      this.XianColumns = []
      // let dataGuid = "77fdf2b0-0eb5-4243-a0a4-6185299ccd34";
      // let searchObject = JSON.stringify([
      //   { field: "pid", value: data, operator: "=" },
      // ]);
      // let token = window.localStorage.getItem("token");
      // let params = {
      //   accessCode: "688bd3883572440a859dfd8ba9194e7b",

      //   cityCode: window.localStorage.getItem("citycode")
      //     ? window.localStorage.getItem("citycode")
      //     : "441300000000",
      //   params: {
      //     dataguid: dataGuid,
      //     searchObject: searchObject,
      //     token: token,
      //   },
      // };
      const res = await getDatalistForTree(data)
      this.XianColumns = res.data.data
      if (this.formData.XCITY) {
        if (this.inUseName(this.formData.XCITY, this.XianColumns)) {
          this.valueXian = this.inUseName(this.formData.XCITY, this.XianColumns)
        }
      }
    },
    getTownOpenDataView: async function (data) {
      this.TownColumns = []
      // let dataGuid = "24d07248-ba49-4b82-9029-b5eccaff179d";
      // let searchObject = JSON.stringify([
      //   { field: "pid", value: data, operator: "=" },
      // ]);
      // let token = window.localStorage.getItem("token");
      // let params = {
      //   accessCode: "688bd3883572440a859dfd8ba9194e7b",

      //   cityCode: window.localStorage.getItem("citycode")
      //     ? window.localStorage.getItem("citycode")
      //     : "441300000000",
      //   params: {
      //     dataguid: dataGuid,
      //     searchObject: searchObject,
      //     token: token,
      //   },
      // };
      const res = await getDatalistForTree(data)
      this.TownColumns = res.data.data
      if (this.formData.ZCITY) {
        if (this.inUseName(this.formData.ZCITY, this.TownColumns)) {
          this.valueZhen = this.inUseName(this.formData.ZCITY, this.TownColumns)
        }
      }
    },
    getCunOpenDataView: async function (data) {
      this.CunColumns = []
      // let dataGuid = "d3aaed7c-84ee-4de3-b70e-07fe188cdc8e";
      // let searchObject = JSON.stringify([
      //   { field: "pid", value: data, operator: "=" },
      // ]);
      // let token = window.localStorage.getItem("token");
      // let params = {
      //   accessCode: "688bd3883572440a859dfd8ba9194e7b",

      //   cityCode: window.localStorage.getItem("citycode")
      //     ? window.localStorage.getItem("citycode")
      //     : "441300000000",
      //   params: {
      //     dataguid: dataGuid,
      //     searchObject: searchObject,
      //     token: token,
      //   },
      // };
      const res = await getDatalistForTree(data)

      this.CunColumns = res.data.data
      if (this.formData.CCITY) {
        if (this.inUseName(this.formData.CCITY, this.CunColumns)) {
          debugger
          this.valueCun = this.inUseName(this.formData.CCITY, this.CunColumns)
        }
      }
    },
    onConfirmCity(value) {
      this.cityCode = value.citycode
      this.ValueCity = value.cityname
      this.formData.SCITY = value.citycode
      this.showPickerC = false
      this.getXianOpenDataView(value.citycode)
      this.getJDGSData()
    },
    onConfirmXian(value) {
      this.valueXian = value.cityname
      this.formData.XCITY = value.citycode
      this.showPickerX = false
      this.getTownOpenDataView(value.citycode)
    },
    onConfirmTown(value) {
      this.valueZhen = value.cityname
      this.formData.ZCITY = value.citycode
      this.showPickerT = false
      this.getCunOpenDataView(value.citycode)
    },
    onConfirmCun(value) {
      this.valueCun = value.cityname
      this.formData.CCITY = value.citycode
      this.showPickerCun = false
      this.formData.cityCode = value.citycode
    },
    onConfirm(value) {
      this.If_ljf = value
      this.formData.If_ljf = value.DICID
      // this.IsLG = value
      this.showPicker = false
    },
    tabClick(index) {
      // if(index==0){
      let self = this
      if (!this.$route.query.data) {
        this.getNHData()
      }
      this.nowIndex = index
      this.IsLG = ''
      if (index == 1) {
        // agentName:'',
        //   agentPhone:'',
        //   agentIdcard:'',
        //   propertyPerson:'',
        //   householderIdcard:'',
        //   householderPhone:'',
        this.isreadonsly1=false,
        this.formDataNew.propertyPerson = ''
        this.formDataNew.householderIdcard = ''
        this.formDataNew.householderPhone = ''
        this.formDataNew.agentName = window.localStorage.getItem('DanDianName')
          ? self.plusXing(window.localStorage.getItem('DanDianName'), 0, 1)
          : ''
        this.formDataNew.agentPhone = window.localStorage.getItem('DanDianPhone')
          ? self.plusXing(window.localStorage.getItem('DanDianPhone'), 3, 5)
          : ''
        this.formDataNew.agentIdcard = window.localStorage.getItem('DanDianid')
          ? self.plusXing(window.localStorage.getItem('DanDianid'), 6, 8)
          : ''
        this.valueXian = ''
        this.valueZhen = ''
        this.valueCun = ''
        this.formDataNew.detailAddress = ''
        this.formDataNew.buildFloor = ''
        this.formDataNew.buildYear = ''
      } else {
        this.searchInformation()
        this.isreadonsly1=true,
        this.formDataNew.agentName = ''
        this.formDataNew.agentPhone = ''
        this.formDataNew.agentIdcard = ''
        this.formDataNew.propertyPerson = window.localStorage.getItem('DanDianName')
          ? self.plusXing(window.localStorage.getItem('DanDianName'), 0, 1)
          : ''
        this.formDataNew.householderIdcard = window.localStorage.getItem('DanDianid')
          ? self.plusXing(window.localStorage.getItem('DanDianid'), 6, 8)
          : ''
        this.formDataNew.householderPhone = window.localStorage.getItem('DanDianPhone')
          ? self.plusXing(window.localStorage.getItem('DanDianPhone'), 3, 5)
          : ''
      }

    },
    onConfirmRQ(val) {
      let year = val.getFullYear()
      let month = val.getMonth() + 1
      let day = val.getDate()
      let hour = val.getHours()
      let minute = val.getMinutes()
      if (month >= 1 && month <= 9) {
        month = `0${month}`
      }
      if (day >= 1 && day <= 9) {
        day = `0${day}`
      }
      if (hour >= 0 && hour <= 9) {
        hour = `0${hour}`
      }
      if (minute >= 0 && minute <= 9) {
        minute = `0${minute}`
      }
      this.formData.JDSJ = `${year}-${month}-${day}`
      this.showPickerq = false
    },
    // 获取是否是困难用户
    getDifficult: async function (data) {
      let params = {
        accessCode: '151b9ef2630611ec87416805cab640a0',
        cityCode: '',
        params: { hzsfzh: window.localStorage.getItem('DanDianid') || data },
      }
      const res = await FileServerProxy(params)
      if (res.data.data) {
        this.formDataNew.userType = '1'
        this.KNLX = '是'
        //如果是困难家庭就显示国难家庭补助申请
        this.ISshowNowKNLX = true
      } else {
        this.formDataNew.userType = '0'
        this.KNLX = '否'
        this.ISshowNowKNLX = false
      }
    },
    getYearsToNow() {
      this.yearsToNow = []
      // this.yearsToNow=[2020,2021,2022]
      //获取到从那一年开始
      let smallYears = 1970
      //获取当前时间
      let date = new Date()
      let nowYears = date.getFullYear()
      let Years = nowYears - smallYears
      let arrYear = []
      for (let i = 0; i <= Years; i++) {
        arrYear.push(nowYears--)
      }
      arrYear.forEach((item) => {
        //下拉框的数组
        this.yearsToNow.push(item)
      })
    },
    // 姓名脱敏
    namePrivate(name) {
      if (null != name && name != undefined) {
        if (name.length == 2) {
          return name.substring(0, 1) + '*' // 截取name的第一个字符，第二个字符变成*
        } else if (name.length == 3) {
          return name.substring(0, 1) + '*' + name.substring(2, 3) // 截取name的第一个和第三个字符，第二个字符变成*
        } else if (name.length > 3) {
          return name.substring(0, 1) + '*' + '*' + name.substring(3, name.length) //截取第一个和大于第4个字符
        }
      } else {
        return ''
      }
    },
    getNHData: async function () {
      let Base64 = require('js-base64').Base64
      let params = 'idCard=' +  window.localStorage.getItem('DanDianid') + '&householderName=' + window.localStorage.getItem('DanDianName')
      const res = await existHouseBaseInfo(params)
      console.log(res)
      if (res.data.data) {
        this.formDataNew.isHasHouse = '1'
        // if (res.data.data.length == 1) {
        //   if (this.formData.ZJH !== Base64.decode(res.data.data[0].HZXX_INFO.HZSFZH)) {
        //     this.showDialogWXTS = true
        //   }
        //   let cityCode = res.data.data[0].FWTYBH_EXT
        //   this.existHouseBaseInfo = res.data.data[0]
        //   this.formData.SQR = this.namePrivate(Base64.decode(res.data.data[0].HZXX_INFO.HZXM))
        //   this.formData.ZJH = Base64.decode(res.data.data[0].HZXX_INFO.HZSFZH).replace(
        //     /^(.{6})(?:\d+)(.{4})$/,
        //     '$1****$2'
        //   )
        //   var pho = /(\d{3})\d*(\d{4})/
        //   res.data.data[0].HZXX_INFO.HZDH
        //
        //   this.formData.SJH = Base64.decode(res.data.data[0].HZXX_INFO.HZDH).replace(pho, '$1****$2')
        //   this.formData.SCITY = cityCode.substring(0, 4) + '00000000'
        //   if (this.inUseName(this.formData.SCITY, this.CityColumns)) {
        //     this.ValueCity = this.inUseName(this.formData.SCITY, this.CityColumns)
        //   }
        //   this.formData.XCITY = cityCode.substring(0, 6) + '000000'
        //   this.getXianOpenDataView(this.formData.SCITY)
        //
        //   this.formData.ZCITY = cityCode.substring(0, 9) + '000'
        //   this.getTownOpenDataView(this.formData.XCITY)
        //   this.formData.CCITY = cityCode
        //   this.getCunOpenDataView(this.formData.ZCITY)
        //   this.formData.CS = res.data.data[0].JZCS
        //   this.formData.NF = res.data.data[0].JSNF
        //   this.formData.FWDZ = res.data.data[0].XXDZ
        // } else {
        //   this.$router.push({
        //     path: '/selectHouse',
        //     query: { data: res.data.data },
        //   })
        // }
      } else {
        this.formDataNew.isHasHouse = '0'
      }
    },
    //获取相关材料1
    getFile: async function (groupGuid, rowGuid) {
      // let groupGuid = [];
      // this.fileData.forEach((item) => {
      //   groupGuid.push(item.groupGuid);
      // });
      // const res1 = await GetFileData({
      //   groupGuid: groupGuid,
      //   toRowGuid: rowGuid,
      // });
      let params = {
        accessCode: '1fdcbce42c6d4748a020feba618d54b8',
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: {
          groupGuid: groupGuid,
          toRowGuid: rowGuid,
          token: window.localStorage.getItem('token'),
        },
      }
      const res = await FileServerProxy(params)
      let data = JSON.parse(res.data.data).FilesInfo
      if (data.length > 0) {
        data.forEach((element) => {
          // this.fileData.forEach((item) => {
          if (element.GROUPGUID == groupGuid) {
            this.getFileUrl(element, groupGuid)

            // item.fileList.push(element);
          }
          // });
        })
      }
    },
    //获取附件文件流
    getFileUrl: async function (element, groupGuid) {
      let formData = new FormData()
      formData.append('accessCode', '98bcf528966e48ce896a8b3fd02d45d5')
      formData.append(
        'cityCode',
        window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000'
      )
      formData.append(
        'paramStr',
        JSON.stringify({
          fileGuid: element.ROW_GUID,
        })
      )
      console.log(111111)
      let response = await dataTransFilePreview(formData)
      console.log(response)
      if (response) {
        var img = new Blob([new Int8Array(response.data, 0)], {
          type: response.headers['content-type'],
        }) //type类型可自定义
        element['isImage'] = true
        element['url'] = window.URL.createObjectURL(img)
        console.log(element)
        if (groupGuid == '19902700-f952-4561-a338-5590056dab65') {
          // item.fileList.push(element);
          this.fileList.push(element)
        } else {
          this.fileList1.push(element)
        }
        console.log(this.fileList)
        console.log(this.fileList1)
      }
    },
    getJDGSData: async function () {
      if(this.formData.SCITY){
        var params = {
          accessCode: "2caf341e427cb1252dd89c8a7bbf0f75",
          cityCode:this.formData.SCITY,
          params: {
            dataguid: "69f6523e-0a8e-41bc-89f2-48573b917a77",
            searchObject: JSON.stringify([
              {field:"FWQY",value:this.formData.SCITY},
              {field:"FWLX",value:447},
            ]),
            token: window.localStorage.getItem("token"),
          },
        };
      } else{
        this.$toast.fail("请选择地市")
      }
      const res = await FileServerProxy(params);
      let data  = JSON.parse(res.data.data).Data;
      console.log(data)
      this.JDGSData = data
    },
  },
  mounted() {
    this.getNHData()
    this.getDifficult()
    let self = this
    if (this.nowIndex == 0) {
      this.searchInformation(window.localStorage.getItem('DanDianid'))
      this.formDataNew.propertyPerson = window.localStorage.getItem('DanDianName')
        ? self.plusXing(window.localStorage.getItem('DanDianName'), 0, 1)
        : ''
      this.formDataNew.householderIdcard = window.localStorage.getItem('DanDianid')
        ? self.plusXing(window.localStorage.getItem('DanDianid'), 6, 8)
        : ''
      // this.formDataNew.householderIdcard = '332623197710090010'
      this.formDataNew.householderPhone = window.localStorage.getItem('DanDianPhone')
        ? self.plusXing(window.localStorage.getItem('DanDianPhone'), 3, 5)
        : ''
    } else {
      this.formDataNew.agentName = window.localStorage.getItem('DanDianName')
        ? self.plusXing(window.localStorage.getItem('DanDianName'), 0, 1)
        : ''
      this.formDataNew.agentPhone = window.localStorage.getItem('DanDianPhone')
        ? self.plusXing(window.localStorage.getItem('DanDianPhone'), 3, 5)
        : ''
      this.formDataNew.agentIdcard = window.localStorage.getItem('DanDianid')
        ? self.plusXing(window.localStorage.getItem('DanDianid'), 6, 8)
        : ''
    }
    this.showEdition = this.$store.state.Edition
    if (this.showEdition) {
      $('#RebuildPanel .van-field__control').css('fontSize', '16px !important')
      $('#RebuildPanel .van-cell').css('fontSize', '16px !important')
    } else {
      $('#RebuildPanel .van-field__control').css('fontSize', '20px !important')
      $('#RebuildPanel .van-cell').css('fontSize', '20px !important')
    }
    //修改苹果手机头部部分内容被遮盖问题
    var scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0
    window.scrollTo(0, Math.max(scrollHeight - 1, 0))
    $('input').on('blur', function () {
      setTimeout(function () {
        var scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0
        window.scrollTo(0, Math.max(scrollHeight - 1, 0))
      }, 100)
    })
    // ----------
    // ;
    if (window.localStorage.getItem('JDData')){
      let JDData = JSON.parse(window.localStorage.getItem('JDData'))
      // console.log()
      this.nowIndex = JDData.nowIndex
      this.formData = JDData.formData
      // this.formData.ZCITY = this.$route.query.data2.ZCITY
      if (this.formData.SCITY) {
        this.getXianOpenDataView(this.formData.SCITY)
      }
      if (this.formData.XCITY) {
        this.getTownOpenDataView(this.formData.XCITY)
      }
      if (this.formData.ZCITY) {
        this.getCunOpenDataView(this.formData.ZCITY)
      }
      // this.getTownOpenDataView(this.formData.XCITY)
      // this.getCunOpenDataView(this.formData.ZCITY)
      // this.formData.CCITY = this.$route.query.data2.CCITY
    }
    //选择鉴定结构
    // if (this.$route.query && this.$route.query.data1 && this.$route.query.data2) {
    //   let data1 = this.$route.query.data1
    //   let data2 = this.$route.query.data2
    //   console.log(data2)
    //   for (let i in this.formDataNew) {
    //     if (data2[i]) {
    //       this.formDataNew[i] = data2[i]
    //     }
    //   }
    //   console.log(data1,'xiaohe')
    //   // this.formData.JDJG = data1.COMAPNY_NAME
    //   // this.formData.TYSHXYDM = data1.TYSHXYDM
    //   this.formDataNew.uscc = data1.TYSHXYDM
    //   this.formData.DWDZ = data1.DWDZ
    //   this.nowIndex = parseInt(this.$route.query.nowIndex)
    //   if (this.nowIndex == 1) {
    //     console.log(this.$route.query.rowGuid)
    //     this.getFile('19902700-f952-4561-a338-5590056dab65', this.$route.query.rowGuid)
    //     this.getFile('d26fd8fd-0d8a-46ec-af9f-2341ba78fb58', this.$route.query.rowGuid)
    //   }
    // }
    //进入页面需要判断困难类型 todo 根据单点登录的身份证号码获取
    if (this.$route.query.rowGuid) {
      this.rowGuid = this.$route.query.rowGuid
    } else {
      this.rowGuid = this.newGuid()
    }
    // try {
    //
    // } catch (e) {
    //
    // }
    if (this.formData.ZJH) {
      this.getDifficult('142525189802134567')
    }
    this.getCityOpenDataView()
    this.getYearsToNow()
    this.getEnumeration()
    this.showEdition = this.$store.state.Edition
    // this.getJFLYOpenDataView()
    // this.getBUILDTYPEcolumns()
    if (this.showEdition) {
      $('#ApplicationPage .van-field__control').css('fontSize', '16px !important')
      $('#ApplicationPage .van-cell').css('fontSize', '16px !important')
    } else {
      $('#ApplicationPage .van-field__control').css('fontSize', '20px !important')
      $('#ApplicationPage .van-cell').css('fontSize', '20px !important')
    }
    console.log(this.$route.query.data);
    // if (JSON.parse(this.$route.query.data).ROW_GUID){
    //   this.rowGuid = JSON.parse(this.$route.query.data).ROW_GUID
    // }else
    // if (this.$route.query.rowGuid){
    //   this.rowGuid = this.$route.query.rowGuid
    // }else{
    //   this.rowGuid = this.newGuid()
    // }
    if (ZWJSBridge) {
      ZWJSBridge.setTitle({
        title: '申请',
      })
        .then((res) => {})
        .catch((err) => {})
    }
  },
}
</script>
<style scoped lang="scss">
#RebuildPanel {
  -webkit-overflow-scrolling: touch;

  /*.van-cell {*/
  /*padding: 10px 0;*/
  /*}*/
  .van-cell {
    padding: 10px 0;
    font-size: 16px;
  }

  .bottomBtn {
    height: 50px;
    background: #007aff;
    line-height: 50px;
    text-align: center;
    color: #ffffff;
    font-weight: bold;
  }

  .bottomText {
    height: 40px;
    line-height: 40px;
    background: #ffffff;
    text-align: center;
  }

  height: 100vh;

  .top {
    height: 90px;
    background: #ffffff;
    padding-top: 25px;
    text-align: center;

    .origin {
      width: 22px;
      height: 22px;
      background: #007aff;
      border-radius: 50%;
      display: inline-block;
    }

    .line {
      width: 20vw;
      /*height: 1px;*/
      border: 1px dashed #007aff;
      display: inline-block;
    }
  }

  .content {
    width: 100%;
    height: calc(100vh - 90px);
    overflow-y: auto;
    background: #ffffff;
    padding: 10px;

    .formStyle {
      display: flex;
      justify-content: center;
      align-items: center;
      border-bottom: 1px solid #d2d2d2;
    }

    .line {
      width: 6px;
      height: 26px;
      background: #007aff;
      display: inline-block;
      margin-right: 10px;
    }

    .list ul li {
      min-height: 50px;
      line-height: 50px;
    }

    .tab {
      height: 40px;
      border-bottom: 1px solid #9b9b9b;

      ul li {
        width: 50%;
        height: 40px;
        line-height: 35px;
        float: left;
        text-align: center;
      }

      .select {
        color: #3f8ffc;
        border-bottom: 5px solid #3f8ffc;
      }
    }
  }
}
</style>
<style>
#RebuildPanel .van-uploader__preview-image {
  width: 180px;
  height: 108px;
}
</style>
